#ifndef _inputmanager_winpc_h__
#define _inputmanager_winpc_h__

#define DIRECTINPUT_VERSION 0x0800
#include <windows.h>
#include <XInput.h>
#include <dinput.h>
#include "input/iinputmanager.h"

namespace gecko
{
	// class to manage pad state and player mapping
	class XboxController
	{
	public:
		// default constructor
		XboxController();

		// the current pad state
		XINPUT_STATE m_padState;

		// the previous pad state (used for getting debounced input)
		XINPUT_STATE m_padPreviousState;

		// is the pad in use
		bool m_active;

		// player associated with pad
		int m_playerID;
	};

	// windows PC specific implementation of input manager
	class InputManager_WinPC : public IInputManager
	{
	public:
		// constructor
		InputManager_WinPC();

		// acquire input device (when window gets focus)
		void AcquireDevices();

		// unacquire input devices (when window loses focus)
		void UnacquireDevices();

	private:
		// initialise platform specific devices
		void InitialiseDevices();

		// shutdown platform specific devices
		void DestroyDevices();

		// poll platform specific devices
		void PollDevices();

		// update "Xbox 360 Controller For Windows" state
		void PollXInputGamepads();

		// get the state of the Windows keyboard
		void PollDirectInputKeyboard();

		// queue up a pad button event
		void QueuePadButtonEvents(int padID, int buttonID, int eventID);

		// queue up a pad axis move event
		void QueuePadAxisEvent(int padID, float axisValue1, float axisValue2, int eventID);

	private:
		// DirectInput
		LPDIRECTINPUT8  m_directInput;

		// keyboard device
		LPDIRECTINPUTDEVICE8  m_keyboardDevice;

		// previous keyboard state
		static const int MAX_KEYS = 256;
		char m_previousKeyBuffer[MAX_KEYS];

		// structs for storing pad states
		static const int MAX_PADS = 4;
		XboxController m_pads[MAX_PADS];
	};

}

#endif // _inputmanager_winpc_h__